using System.Collections.Generic;
using TK.Character;
using TK.Skill;
using TK.SKill;

namespace TK.Event
{
    /// <summary>
    /// 事件数据对象
    /// </summary>
    public class EventData
    {

    }

    /// <summary>
    /// 单位事件数据对象
    /// </summary>
    public class UnitEventData : EventData
    {
        public UnitEventData(Unit target,Unit source)
        {
            Target = target;
            Source = source;
        }
        /// <summary>
        /// 目标单位
        /// </summary>
        public Unit Target { get; set; }

        /// <summary>
        /// 来源单位
        /// </summary>
        public Unit Source { get; set; }
    }

    /// <summary>
    /// 单位伤害事件
    /// </summary>
    public class UnitDamageEventData:UnitEventData
    {
        public UnitDamageEventData(Unit target, Unit source,float amount,params DamageType[] type) : base(target, source)
        {
            Amount = amount;
            DamageType = new List<DamageType>();
            DamageType.AddRange(type);
        }
        /// <summary>
        /// 伤害数值
        /// </summary>
        public float Amount { get; set; }

        /// <summary>
        /// 伤害类型
        /// </summary>
        public List<DamageType> DamageType { get; set; }

        /// <summary>
        /// 判断伤害类型
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public bool IsDamageType(DamageType type)
        {
            return DamageType.Contains(type);
        }

        /// <summary>
        /// 是否物理伤害
        /// </summary>
        public bool IsPhysicalDamage => IsDamageType(SKill.DamageType.Physical);
        /// <summary>
        /// 是否土系伤害
        /// </summary>
        public bool IsEarthDamage => IsDamageType(SKill.DamageType.Earth);
        /// <summary>
        /// 是否火系伤害
        /// </summary>
        public bool IsFireDamage => IsDamageType(SKill.DamageType.Fire);
        /// <summary>
        /// 是否冰系伤害
        /// </summary>
        public bool IsIceDamage => IsDamageType(SKill.DamageType.Ice);
        /// <summary>
        /// 是否金系伤害
        /// </summary>
        public bool IsMetalDamage => IsDamageType(SKill.DamageType.Metal);
        /// <summary>
        /// 是否反伤
        /// </summary>
        public bool IsReturnInjuryDamage => IsDamageType(SKill.DamageType.ReturnInjury);
        /// <summary>
        /// 是否木系伤害
        /// </summary>
        public bool IsWoodDamage => IsDamageType(SKill.DamageType.Wood);
    }

    /// <summary>
    /// 单位攻击事件
    /// </summary>
    public class UnitAttackEventData : UnitDamageEventData
    {
        /// <summary>
        /// 攻击类型
        /// </summary>
        public AttackType AttackType { get; set; }

        public UnitAttackEventData(Unit target, Unit source, float amount, AttackType aType,params DamageType[] dType) : base(target, source, amount, dType)
        {
            AttackType = aType;
        }

        /// <summary>
        /// 判断伤害类型
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public bool IsAttackType(AttackType type)
        {
            return AttackType == type;
        }

        /// <summary>
        /// 是否近战伤害
        /// </summary>
        public bool IsMeleeAttack => IsAttackType(AttackType.Melee);

        /// <summary>
        /// 是否远程伤害
        /// </summary>
        public bool IsRangeAttack => IsAttackType(AttackType.Range);
    }

    /// <summary>
    /// 单位治疗事件数据对象
    /// </summary>
    public class UnitHealEventData:UnitEventData
    {
        public UnitHealEventData(Unit target, Unit source,float amount) : base(target, source)
        {
            Amount = amount;
        }

        public float Amount { get; set; }
    }

    /// <summary>
    /// 单位开始施法事件数据对象
    /// </summary>
    public class UnitSpellStartEventData : UnitEventData
    {
        public UnitSpellStartEventData(Unit target, Unit source) : base(target, source)
        {
        }
    }

    /// <summary>
    /// 单位施法结束事件数据对象
    /// </summary>
    public class UnitSpellEndEventData : UnitEventData
    {
        public UnitSpellEndEventData(Unit target, Unit source) : base(target, source)
        {
        }
    }

    /// <summary>
    /// 单位施法失败事件数据对象
    /// </summary>
    public class UnitSpellFailedEventData:UnitEventData
    {
        public UnitSpellFailedEventData(Unit target, Unit source) : base(target, source)
        {
        }
    }
}
